package com.lge.pitchingcoins.ui.server;

import android.app.Activity;
import android.content.Intent;
import android.net.ConnectivityManager;
import android.net.NetworkInfo;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.Button;
import android.widget.TextView;
import android.widget.Toast;

import com.lge.pitchingcoins.R;
import com.lge.pitchingcoins.util.PitchingCoinsLog;
import com.lge.pitchingcoins.util.Util;

@Deprecated
public class ServerMainActivity extends Activity implements OnClickListener {
    public static String TAG = "PitchingCoins";

    private Button gameConnectButton = null;
    private Button settingsButton = null;
    private TextView highscoreTextView = null;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.activity_server_main);

        initComponents();
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
        case R.id.gameConnectButton:
            gameConnectButtonPressed();
            break;
        case R.id.settingsButton:
            settingsButtonPressed();
            break;
        }
    }


    // Member Methods
    public void initComponents() {
        gameConnectButton = (Button)findViewById(R.id.gameConnectButton);
        settingsButton = (Button)findViewById(R.id.settingsButton);
        highscoreTextView = (TextView)findViewById(R.id.highscoreTextView);

        gameConnectButton.setOnClickListener(this);
        settingsButton.setOnClickListener(this);
    }

    public void gameConnectButtonPressed() {
        ConnectivityManager connectivityManager = (ConnectivityManager)getSystemService(CONNECTIVITY_SERVICE);
        NetworkInfo networkInfoForWifi = connectivityManager.getNetworkInfo(ConnectivityManager.TYPE_WIFI);

        if (networkInfoForWifi.isConnected()) {
            Intent intent = new Intent(ServerMainActivity.this, GameConnectForServerActivity.class);
            startActivity(intent);
        } else {
            Toast.makeText(getApplicationContext(), getString(R.string.requireWifiConnectionText), Toast.LENGTH_SHORT).show();
        }
    }

    public void settingsButtonPressed() {

    }
}